import random

from log.ip import get_ip_requests,get_ip_poll
import requests

ip_poll = get_ip_poll()
urls =[f'https://httpbin.org/get?age={i}' for i in range(1,100)]


while len(urls)>0:

    url = urls.pop()
    proxy = random.choice(ip_poll)

    try:
        res = requests.get(url, proxies=proxy)
        print(res.url)
    except requests.exceptions.ProxyError as e:
        print('代理失败')
        ip_poll.remove(proxy)
        urls.append(url)
        ip_poll.append(get_ip_requests())
    except Exception as e:
        print(f'未知错误----{e}')
        urls.append(url)

